﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using ZhimeiSoft.Framework.Client.Base;
using ZhimeiSoft.CharmManager.DOL;
using ZhimeiSoft.Framework.Client.Utils;
using ZhimeiSoft.CharmManager.Client.Manager;
using ZhimeiSoft.CharmManager.Client.Interface;

namespace ZhimeiSoft.CharmManager.Client.Forms
{
    public partial class MonthReservationEmployee : BaseUserControl
    {
        private DataSet dsEmployeeInfos = new DataSet();

        public MonthReservationEmployee()
        {
            InitializeComponent();
            dateTimeInput.Value = DateTime.Now;
        }

        private void buttonX1_Click(object sender, EventArgs e)
        {
            queryReservation(dateTimeInput.Value);
        }

        private void MonthReservationEmployee_Load(object sender, EventArgs e)
        {
            string error = string.Empty;
            if (BussinessProxyManager.Instance == null)
            {
                return;
            }
            if (!BussinessProxyManager.Instance.QueryEmployeeState(DBEntityEmployee.ENUM_ESTATE.F0E, out dsEmployeeInfos, out error))
            {
                MsgBox.MsgInfo("获取员工信息错误：" + error);
                return;
            }

            queryReservation(dateTimeInput.Value);
        }

        private void queryReservation(DateTime queryTime)
        {
            if (BussinessProxyManager.Instance == null)
            {
                return;
            }
            string error = string.Empty;
            DataSet dsReservationServiceItem = new DataSet();

            if (!BussinessProxyManager.Instance.QueryReservationEmployee(queryTime.Year, queryTime.Month, queryTime.Day, -1,
                string.Empty, out dsReservationServiceItem, out error))
            {
                MsgBox.MsgInfo("获取员工预约信息错误：" + error);
                return;
            }

            todayReservationEmployee.DataBind(dsEmployeeInfos.Tables[0], queryTime, dsReservationServiceItem);
        }
    }
}
